package robocup.component.infotypes;

import robocup.component.geometry.Vektor;
import robocup.component.worldobjects.Player;

/**
 * The Player how it is seen by the coach. The speed and position are not noisy,
 * and were directly given by the server.
 */
public class CoachPlayerInfo
    extends CoachVisualObjectInfo {

  /**
   * The teamName of the corresponding player.
   */
  protected String  teamName;

  /**
   * The tricot-number of the player.
   */
  protected int     playerNumber;

  /**
   * The speed in x-direction.
   */
  protected double  xSpeed;

  /**
   * The speed in y-direction.
   */
  protected double  ySpeed;

  /**
   * The players body direction.
   */
  protected double  bodyAngle;

  /**
   * The players neck-angle.
   */
  protected double  neckAngle;

  /**
   * The players pointing direction.
   */
  protected double  pointDirection;

  /**
   * Flag, that indicates, that the player has tackled lately, and is therefore
   * not able to move.
   */
  protected boolean tackle;

  /**
   * Identifier for the goalie.
   */
  protected boolean goalie;

  /**
   * Constructs an info-object of a seen player for the coach
   * 
   * @param team -
   *          his team-name
   * @param iCycle -
   *          when the agent was seen
   * @param xPos -
   *          his position (x-value)
   * @param yPos -
   *          his position (y-value)
   * @param xSpeed -
   *          his speed (in x-direction)
   * @param ySpeed -
   *          his speed (in y-direction)
   * @param playerNumber -
   *          his player number
   * @param bodyAngle -
   *          his body angle
   * @param neckAngle -
   *          his neck-angle
   * @param pointDirection -
   *          the direction he is pointing to
   * @param goalie -
   *          wether he is a goalie or not
   * @param tackle -
   *          wether he has tackled or not
   */
  public CoachPlayerInfo(
      final String team,
      final int iCycle,
      final double xPos,
      final double yPos,
      final double xSpeed,
      final double ySpeed,
      final int playerNumber,
      final double bodyAngle,
      final double neckAngle,
      final double pointDirection,
      final boolean goalie,
      final boolean tackle) {

    super(iCycle, xPos, yPos);
    this.teamName = team;
    this.playerNumber = playerNumber;
    this.xSpeed = xSpeed;
    this.ySpeed = ySpeed;
    this.bodyAngle = bodyAngle;
    this.neckAngle = neckAngle;
    this.pointDirection = pointDirection;
    this.goalie = goalie;
    this.tackle = tackle;
  }

  /**
   * Sets the seen body-angle.
   * 
   * @param bodyAngle
   */
  public void setBodyAngle(final double bodyAngle) {

    this.bodyAngle = bodyAngle;
  }

  /**
   * Sets the seen neck-angle.
   * 
   * @param nackAngle
   */
  public void setNeckAngle(final double neckAngle) {

    this.neckAngle = neckAngle;
  }

  /**
   * Sets the seen playerNumber.
   * 
   * @param playerNumber
   */
  public void setPlayerNumber(final int playerNumber) {

    this.playerNumber = playerNumber;
  }

  /**
   * Sets the seen pointDirection
   * 
   * @param pointDirection
   */
  public void setPointDirection(final double pointDirection) {

    this.pointDirection = pointDirection;
  }

  /**
   * Sets the seen tackle-flag.
   * 
   * @param tackle
   */
  public void setTackle(final boolean tackle) {

    this.tackle = tackle;
  }

  /**
   * Sets the seen x-component of the speed.
   * 
   * @param speed
   */
  public void setXSpeed(final double speed) {

    this.xSpeed = speed;
  }

  /**
   * Sets the seen y-component of the speed.
   * 
   * @param speed
   */
  public void setYSpeed(final double speed) {

    this.ySpeed = speed;
  }

  /**
   * @return Returns the bodyAngle.
   */
  public double getBodyAngle() {

    return this.bodyAngle;
  }

  /**
   * @return Returns the neckAngle.
   */
  public double getNeckAngle() {

    return this.neckAngle;
  }

  /**
   * @return Returns the playerNumber.
   */
  public int getPlayerNumber() {

    return this.playerNumber;
  }

  /**
   * @return Returns the pointDirection.
   */
  public double getPointDirection() {

    return this.pointDirection;
  }

  /**
   * @return Returns the tackle.
   */
  public boolean isTackle() {

    return this.tackle;
  }

  /**
   * @return Returns the xSpeed.
   */
  public double getXSpeed() {

    return this.xSpeed;
  }

  /**
   * @return Returns the ySpeed.
   */
  public double getYSpeed() {

    return this.ySpeed;
  }

  /**
   * @return Returns true, if the player was seen as goalie.
   */
  public boolean isGoalie() {

    return this.goalie;
  }

  /**
   * Sets the flag, that the player was seen as goalie.
   * 
   * @param goalie
   */
  public void setGoalie(final boolean goalie) {

    this.goalie = goalie;
  }

  /**
   * @return Returns the team-name of the seen player.
   */
  public String getTeamName() {

    return this.teamName;
  }

  /**
   * Sets the teamname of the seen player.
   * 
   * @param teamName
   */
  public void setTeamName(final String teamName) {

    this.teamName = teamName;
  }

  /**
   * Creates and returns an instance of the class player, which corresponds to
   * the seen information.
   * 
   * @return Player - a player object craeted due to the seen information.
   */
  public Player getPlayer() {

    final Player p = new Player(this.getCycle(), this.getCycle(), this
        .getPlayerNumber(), new Vektor(Vektor.XY, this.getXPos(), this
        .getYPos()), new Vektor(Vektor.XY, this.getXSpeed(), this.getYSpeed()),
        this.getBodyAngle(), this.getNeckAngle(), 0, 0, 0, false, false, // not
                                                                          // known
                                                                          // here
        this.isGoalie(), null);
    return p;
  }
}
